namespace GemBox.Spreadsheet
{
    using System;

    public sealed class ExcelPrintOptions
    {
        private ExcelWorksheet parent;

        internal ExcelPrintOptions(ExcelWorksheet parent)
        {
            this.parent = parent;
        }

        public int AutomaticPageBreakScalingFactor
        {
            get
            {
                return this.parent.scalingFactor;
            }
            set
            {
                if ((value < 10) || (value > 400))
                {
                    throw new ArgumentOutOfRangeException("value", value, "AutomaticPageBreakScalingFactor must be in range from 10 to 400.");
                }
                this.parent.scalingFactor = value;
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 4, false);
                this.FitToPage = false;
            }
        }

        public double BottomMargin
        {
            get
            {
                return this.parent.bottomMargin;
            }
            set
            {
                this.parent.bottomMargin = value;
            }
        }

        public bool DraftQuality
        {
            get
            {
                return Utilities.IsBitSet((ushort) this.parent.setupOptions, 0x10);
            }
            set
            {
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 0x10, value);
            }
        }

        public bool FitToPage
        {
            get
            {
                return this.parent.GetWSBoolOption(WSBoolOptions.FitToPage);
            }
            set
            {
                this.parent.SetWSBoolOption(value, WSBoolOptions.FitToPage);
            }
        }

        public int FitWorksheetHeightToPages
        {
            get
            {
                return this.parent.fitWorksheetHeightToPages;
            }
            set
            {
                this.parent.fitWorksheetHeightToPages = (ushort) value;
                this.FitToPage = true;
            }
        }

        public int FitWorksheetWidthToPages
        {
            get
            {
                return this.parent.fitWorksheetWidthToPages;
            }
            set
            {
                this.parent.fitWorksheetWidthToPages = (ushort) value;
                this.FitToPage = true;
            }
        }

        public double FooterMargin
        {
            get
            {
                return this.parent.footerMargin;
            }
            set
            {
                this.parent.footerMargin = value;
            }
        }

        public double HeaderMargin
        {
            get
            {
                return this.parent.headerMargin;
            }
            set
            {
                this.parent.headerMargin = value;
            }
        }

        public double LeftMargin
        {
            get
            {
                return this.parent.leftMargin;
            }
            set
            {
                this.parent.leftMargin = value;
            }
        }

        public int NumberOfCopies
        {
            get
            {
                return this.parent.numberOfCopies;
            }
            set
            {
                this.parent.numberOfCopies = (ushort) value;
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 4, false);
            }
        }

        public int PaperSize
        {
            get
            {
                return this.parent.paperSize;
            }
            set
            {
                this.parent.paperSize = (ushort) value;
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 4, false);
            }
        }

        public bool Portrait
        {
            get
            {
                return Utilities.IsBitSet((ushort) this.parent.setupOptions, 2);
            }
            set
            {
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 2, value);
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 4, false);
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 0x40, false);
            }
        }

        public bool PrintBlackWhite
        {
            get
            {
                return Utilities.IsBitSet((ushort) this.parent.setupOptions, 8);
            }
            set
            {
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 8, value);
            }
        }

        public bool PrintCellNotes
        {
            get
            {
                return Utilities.IsBitSet((ushort) this.parent.setupOptions, 0x20);
            }
            set
            {
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 0x20, value);
            }
        }

        public bool PrintNotesSheetEnd
        {
            get
            {
                return Utilities.IsBitSet((ushort) this.parent.setupOptions, 0x200);
            }
            set
            {
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 0x200, value);
            }
        }

        public bool PrintPagesInRows
        {
            get
            {
                return Utilities.IsBitSet((ushort) this.parent.setupOptions, 1);
            }
            set
            {
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 1, value);
            }
        }

        public int PrintResolution
        {
            get
            {
                return this.parent.printResolution;
            }
            set
            {
                this.parent.printResolution = (ushort) value;
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 4, false);
            }
        }

        public double RightMargin
        {
            get
            {
                return this.parent.rightMargin;
            }
            set
            {
                this.parent.rightMargin = value;
            }
        }

        public int StartPageNumber
        {
            get
            {
                return this.parent.startPageNumber;
            }
            set
            {
                this.parent.startPageNumber = (ushort) value;
            }
        }

        public double TopMargin
        {
            get
            {
                return this.parent.topMargin;
            }
            set
            {
                this.parent.topMargin = value;
            }
        }

        public bool UseStartPageNumber
        {
            get
            {
                return Utilities.IsBitSet((ushort) this.parent.setupOptions, 0x80);
            }
            set
            {
                this.parent.setupOptions = (SetupOptions) Utilities.SetBit((ushort) this.parent.setupOptions, (ushort) 0x80, value);
            }
        }

        public int VerticalPrintResolution
        {
            get
            {
                return this.parent.verticalPrintResolution;
            }
            set
            {
                this.parent.verticalPrintResolution = (ushort) value;
            }
        }
    }
}
